package org.chen.common.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;

import java.io.Serial;

@EqualsAndHashCode(callSuper = true)
@Data
public class ServiceException extends RuntimeException {
    @Serial
    private static final long serialVersionUID = 1123213L;
    
    /**
     * 错误码
     */
    private Integer code;
    
    /**
     * 错误消息
     */
    private String message;
    
    public ServiceException(String message) {
        this.message = message;
        this.code = 500;
    }
    
    public ServiceException(String message, Integer code) {
        this.message = message;
        this.code = code;
    }
    
    public ServiceException(String message, Throwable e) {
        super(message, e);
        this.message = message;
        this.code = 500;
    }
}